package com.school.controller;

import com.school.entity.Student;
import com.school.entity.Users;
import com.school.service.StudentService;
import com.school.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/stu")
public class StudentController {
    @Autowired
    StudentService service;

    @Autowired
    UsersService usersService;

    @RequestMapping("/add.do")
    public @ResponseBody
    Student add(int stuNum, String stuName) {
        Student student = new Student(stuNum, stuName);
        System.out.println("student = " + student);
        return student;
    }


    @RequestMapping(value = "/add1.do")
    public void add1(String x) {
        System.out.println("x = " + x);
        System.out.println("service = " + service);
        System.out.println("usersService = " + usersService);
        Users users = new Users("22", "1");
        System.out.println("usersService.selectOne(users) = " + usersService.selectOne(users));
    }

    @RequestMapping("/add2.do")
    @ResponseBody
    public Student add2(HttpServletRequest request, HttpServletResponse response) {
        Student student = new Student(1, "stuName");
        System.out.println("student = " + student);
        return student;
    }
}
